Skip to content

fix: Correct dpad axis mapping and add support for start/select/home buttons (iOS)#65

Merged
spydon merged 1 commit intoflame-engine:mainfrom
wantroba:main
Jul 9, 2025
Merged

fix: Correct dpad axis mapping and add support for start/select/home buttons (iOS)#65
spydon merged 1 commit intoflame-engine:mainfrom
wantroba:main

Conversation

@wantroba
Copy link
Contributor

I rewrote GamepadsIosPlugin.swift following Apple's documentation https://developer.apple.com/documentation/gamecontroller and also keeping the plugin consistent and working.

With this I fixed the dpad axis mapping issue that appeared in #64. In addition, now the buttons buttonMenu, buttonOptions and buttonHome are also mapped when available.

Note: The only thing I couldn't keep was the timestamp that used to come from the event, now the time is generated by the plugin. If there is a need and a way to retrieve this value please let me know or correct my code for it.

@wantroba wantroba changed the title fix(iOS/GamepadsIosPlugin): correct dpad axis mapping and add support for start/select/home buttons fix: correct dpad axis mapping and add support for start/select/home buttons (iOS) Jun 23, 2025
@wantroba wantroba changed the title fix: correct dpad axis mapping and add support for start/select/home buttons (iOS) fix: Correct dpad axis mapping and add support for start/select/home buttons (iOS) Jun 23, 2025
Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think genering the timestamp is totally fine if one is not provided by the platform.

@spydon spydon merged commit 1aef0c2 into flame-engine:main Jul 9, 2025
6 of 8 checks passed
@gyenesvi
Copy link

gyenesvi commented Mar 7, 2026

Hi,

It seems to me that this fix introduced some incorrect behaviour that was working correctly before. I recently updated the gamepads package to the latest version and noticed that all button keys have been renamed on iOS, which in itself is a breaking change, but I can understand that with this package being under development. So I did a remapping, and I realised that the left/right triggers on an Xbox Series controller are now acting as non-analog buttons, whereas previously were acting as analog ones. Also, when I tested my controller with other apps, the triggers were read as analog ones. Then I saw this update, in which it seems the whole status update logic has been reworked with the button keys remapped. In this code, the triggers are explicitly treated as non-analog buttons, so no wonder for the observed behaviour. I had to go back to version 0.1.2+2 of the gamepads_ios package to get back the analog behaviour, with which it is indeed working again.

Another missing feature I noticed is that the 'home' button on the Xbox controller isn't getting mapped with the latest version, while it did get mapped with the older version of the code (the 'options' and 'menu' buttons do work).

Also, the d-pad is now mapped as an analog button, whereas previously it was non-analog, which seems to be a better fit. Are there controllers on which the signal is actually analog? Also, the older version is working fine for me for the dead, getting -1, 0, 1 values across both axes.

I'm not sure what the required change would be for these issues, but from the older version working properly I guess it should be doable, and it should be fixed in order not to lose previously existing functionality.

By the way, can I ask what was the fundamental problem with the previous code logic that warranted the substantial reworking?

@wantroba could you please look into these issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants